<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="css/style.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
function ketqua()
{
	var so1=document.getElementById('toan').value;
	var so2=document.getElementById('ly').value;
	var so3=document.getElementById('hoa').value;
	var so4=document.getElementById('van').value;
	var so5=document.getElementById('su').value;
	var so6=document.getElementById('dia').value;
	if(isNaN(so1) || isNaN(so2) ||isNaN(so3)| isNaN(so4)|| isNaN(so5) || isNaN(so6))
	{
		alert('ban nhap so khong hop le');
	}
	else if(so1.length==0 || so2.length==0 || so3.length==0 || so4.length==0 || so5.length==0 || so6.length==0)
	{
		alert('ban khong duoc nhap rong');
	}
	
	else 
	{
		var trungbinh=((parseFloat(so1)*3)+(parseFloat(so2)*2)+parseFloat(so3)+parseFloat(so4)+parseFloat(so5)+parseFloat(so6))/9;
		document.getElementById('result').value=trungbinh;
		if(trungbinh>=8)
		{
			document.getElementById('xl').value='gioi';
		}
		else if(trungbinh>=7 && trungbinh<8)
		{
			document.getElementById('xl').value='kha gioi';
		}
		else if(trungbinh>=6 && trungbinh<7)
		{
			document.getElementById('xl').value='kha';
		}
		else if(trungbinh>=5 && trungbinh<6)
		{
			document.getElementById('xl').value='trung binh';
		}
		else if(trungbinh<5)
		{
			document.getElementById('xl').value='yeu';
		}
	}
	
}
</script>
</head>

<body>

      <table border="0" >
         <tr>
           <th>Toan</th>
           <td><input type="text" id="toan" /></td>
           <th>Ly</th>
           <td><input type="text" id="ly" /></td>
         </tr>
            <tr>
           <th>Hoa</th>
           <td><input type="text" id="hoa" /></td>
           <th>Vans</th>
           <td><input type="text" id="van" /></td>
         </tr>
            <tr>
           <th>Su</th>
           <td><input type="text" id="su" /></td>
           <th>Dia</th>
           <td><input type="text" id="dia" /></td>
         </tr>
            <tr>
           <th>diem trung binh</th>
           <td>&nbsp;</td>
           <td><input type="text" id="result" /></td>
           <td>&nbsp;</td>
         </tr>
            
           <th>Xep Loai</th>
           <td>&nbsp;</td>
           <td><input type="text" id="xl" /></td>
           <td>&nbsp;</td>
         </tr>
         <tr>
            <td></td>
             <td><input type="button" value="ket qua" onclick="ketqua()" /></td>
              <td></td>
               <td></td>
         </tr>
      </table>
</body>
</html>
